//
//  LGConsultRecordLineView.m
//  HeartDiseaseManage
//
//  Created by 1234 on 2023/10/23.
//

#import "LGConsultRecordLineView.h"

@interface LGConsultRecordLineView()
/**   */
@property (nonatomic , strong)UIImageView *iconView;
/**   */
@property (nonatomic , strong)UILabel *titleLabel;

@end

@implementation LGConsultRecordLineView

- (instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        self.backgroundColor = [UIColor whiteColor];
        [self setShadoWithColor:@"#B2BDC7" offset:CGSizeMake(0, 2) opacity:0.15 radius:15];
        [self addSubview:self.iconView];
        [self addSubview:self.titleLabel];
        [self addSubview:self.contentTF];
        [self.iconView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self).offset(viewPix(12));
            make.width.height.equalTo(@(viewPix(6)));
            make.centerY.equalTo(self);
        }];
        [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self).offset(viewPix(12));
            make.centerY.equalTo(self);
        }];
    }
    return self;
}

-(void)setTitle:(NSString *)title{
    _title = _title;
    self.titleLabel.text = title;
}

-(void)setRequired:(BOOL)required{
    _required = required;
    self.iconView.hidden = !required;
    CGFloat leftMargin = (required == YES)?viewPix(20):viewPix(12);
    [self.titleLabel mas_updateConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self).offset(leftMargin);
    }];
}

-(UIImageView *)iconView{
    if(!_iconView){
        _iconView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"必选项"]];
    }
    return _iconView;
}
-(UILabel *)titleLabel{
    if(!_titleLabel){
        _titleLabel = [UILabel lableWithText:@"" colorString:@"#333333" textFont:LGFontWeight(16, UIFontWeightMedium) textAlignment:NSTextAlignmentLeft lines:1];
    }
    return _titleLabel;
}

-(UITextField *)contentTF{
    if(!_contentTF){
        _contentTF = [[UITextField alloc]initWithFrame:CGRectMake(viewPix(100), 0, Screen_W-viewPix(144), viewPix(54))];
        _contentTF.tintColor = [UIColor colorWithString:@"#333333"];
        _contentTF.textColor = [UIColor colorWithString:@"#333333"];
        _contentTF.textAlignment = NSTextAlignmentRight;
        _contentTF.keyboardType = UIKeyboardTypeDefault;
        _contentTF.placeholder = @"请输入";
        _contentTF.font = LGFont(14);
    }
    return _contentTF;
}

@end
